<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

use DB;

class Comcheckagain extends Model
{
    //
    protected $table = 'comcheckagain';
    public $timestamps = false;

    protected $fillable = ['companyId','groupId', 'userId','checkId', 'remark','checkTime','companySign','checkSign','wordsUrl','status','from'];

    public function getDangerNum()
    {
    	$sql = "select ccka.id,ccka.companyId,ccka.checkId,
    			(select count(cckad.id) from comcheckagaindetail as cckad where ccka.id=cckad.checkId and cckad.status<>3) as num 
    			from (select * from comcheckagain order by checkTime DESC) as ccka
   				group by ccka.checkId";
    	$res = DB::select($sql);
    	return $res;
    }

}
